<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Softmax Functions</title>
<title>CMSIS-NN: Softmax Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="printComponentTabs.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 46px;">
  <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMSIS-NN
   &#160;<span id="projectnumber">Version 1.2.0</span>
   </div>
   <div id="projectbrief">CMSIS NN Software Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
    <ul class="tablist">
      <script type="text/javascript">
		<!--
		writeComponentTabs.call(this);
		//-->
      </script>
	  </ul>
</div>
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__Softmax.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Softmax Functions<div class="ingroups"><a class="el" href="group__groupNN.html">Neural Network Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>EXP(2) based softmax functions.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga3313178e0fcf9138c3cc3b071a043238"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#ga3313178e0fcf9138c3cc3b071a043238">Q7BITS</a></td></tr>
<tr class="memdesc:ga3313178e0fcf9138c3cc3b071a043238"><td class="mdescLeft">&#160;</td><td class="mdescRight">Q7 softmax function.  <a href="group__Softmax.html#ga3313178e0fcf9138c3cc3b071a043238">More...</a><br /></td></tr>
<tr class="separator:ga3313178e0fcf9138c3cc3b071a043238"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga99133c0c13daf247a40419a385d29190"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#ga99133c0c13daf247a40419a385d29190">LOG2Q7BITS</a></td></tr>
<tr class="separator:ga99133c0c13daf247a40419a385d29190"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga1cacd8b84b8363079311987d0016ebe5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#ga1cacd8b84b8363079311987d0016ebe5">arm_softmax_q15</a> (const q15_t *vec_in, const uint16_t dim_vec, q15_t *p_out)</td></tr>
<tr class="memdesc:ga1cacd8b84b8363079311987d0016ebe5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Q15 softmax function.  <a href="group__Softmax.html#ga1cacd8b84b8363079311987d0016ebe5">More...</a><br /></td></tr>
<tr class="separator:ga1cacd8b84b8363079311987d0016ebe5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga89aff212a97a3cf32d9d7ddf11a8f43e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#ga89aff212a97a3cf32d9d7ddf11a8f43e">arm_softmax_q7</a> (const q7_t *vec_in, const uint16_t dim_vec, q7_t *p_out)</td></tr>
<tr class="memdesc:ga89aff212a97a3cf32d9d7ddf11a8f43e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Q7 softmax function.  <a href="group__Softmax.html#ga89aff212a97a3cf32d9d7ddf11a8f43e">More...</a><br /></td></tr>
<tr class="separator:ga89aff212a97a3cf32d9d7ddf11a8f43e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad04612a258414266a706b58ca258dc1d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#gad04612a258414266a706b58ca258dc1d">arm_softmax_s8</a> (const int8_t *input, const int32_t num_rows, const int32_t row_size, const int32_t mult, const int32_t shift, const int8_t diff_min, int8_t *output)</td></tr>
<tr class="memdesc:gad04612a258414266a706b58ca258dc1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">S8 softmax function.  <a href="group__Softmax.html#gad04612a258414266a706b58ca258dc1d">More...</a><br /></td></tr>
<tr class="separator:gad04612a258414266a706b58ca258dc1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa1627ed96bd597a8046d00689f077dce"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#gaa1627ed96bd597a8046d00689f077dce">arm_softmax_u8</a> (const uint8_t *input, const int32_t num_rows, const int32_t row_size, const int32_t mult, const int32_t shift, const int32_t diff_min, uint8_t *output)</td></tr>
<tr class="memdesc:gaa1627ed96bd597a8046d00689f077dce"><td class="mdescLeft">&#160;</td><td class="mdescRight">U8 softmax function.  <a href="group__Softmax.html#gaa1627ed96bd597a8046d00689f077dce">More...</a><br /></td></tr>
<tr class="separator:gaa1627ed96bd597a8046d00689f077dce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga894cfd80c260b946702755b5754e520f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Softmax.html#ga894cfd80c260b946702755b5754e520f">arm_softmax_with_batch_q7</a> (const q7_t *vec_in, const uint16_t nb_batches, const uint16_t dim_vec, q7_t *p_out)</td></tr>
<tr class="memdesc:ga894cfd80c260b946702755b5754e520f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Q7 softmax function with batch parameter.  <a href="group__Softmax.html#ga894cfd80c260b946702755b5754e520f">More...</a><br /></td></tr>
<tr class="separator:ga894cfd80c260b946702755b5754e520f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga99133c0c13daf247a40419a385d29190"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga99133c0c13daf247a40419a385d29190">&#9670;&nbsp;</a></span>LOG2Q7BITS</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LOG2Q7BITS</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="ga3313178e0fcf9138c3cc3b071a043238"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3313178e0fcf9138c3cc3b071a043238">&#9670;&nbsp;</a></span>Q7BITS</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define Q7BITS</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">vec_in</td><td>pointer to input vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dim_vec</td><td>input vector dimention </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_out</td><td>pointer to output vector</td></tr>
  </table>
  </dd>
</dl>
<p>Here, instead of typical natural logarithm e based softmax, we use 2-based softmax here, i.e.,:</p>
<p>y_i = 2^(x_i) / sum(2^x_j)</p>
<p>The relative output will be different here. But mathematically, the gradient will be the same with a log(2) scaling factor.</p>
<p>If we compare the position of the max value in output of this function with a reference float32 softmax (and thus using exp) we see that the position of the max value is sometimes different.</p>
<p>If we do statistics on lot of input vectors we can compute an average error rate in percent. It is the percent of time that the max will be at a position different from the one computed with a reference float32 implementation.</p>
<p>This average error rate is dependent on the vector size. We have:</p>
<p>Average error rate in percent = -0.555548 + 0.246918 dim_vec Variance of the error rate = -0.0112281 + 0.0382476 dim_vec </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga1cacd8b84b8363079311987d0016ebe5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1cacd8b84b8363079311987d0016ebe5">&#9670;&nbsp;</a></span>arm_softmax_q15()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_softmax_q15 </td>
          <td>(</td>
          <td class="paramtype">const q15_t *&#160;</td>
          <td class="paramname"><em>vec_in</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t&#160;</td>
          <td class="paramname"><em>dim_vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">q15_t *&#160;</td>
          <td class="paramname"><em>p_out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">vec_in</td><td>pointer to input vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dim_vec</td><td>input vector dimention </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_out</td><td>pointer to output vector</td></tr>
  </table>
  </dd>
</dl>
<p>Here, instead of typical e based softmax, we use 2-based softmax, i.e.,:</p>
<p>y_i = 2^(x_i) / sum(2^x_j)</p>
<p>The relative output will be different here. But mathematically, the gradient will be the same with a log(2) scaling factor. </p>

</div>
</div>
<a id="ga89aff212a97a3cf32d9d7ddf11a8f43e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga89aff212a97a3cf32d9d7ddf11a8f43e">&#9670;&nbsp;</a></span>arm_softmax_q7()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_softmax_q7 </td>
          <td>(</td>
          <td class="paramtype">const q7_t *&#160;</td>
          <td class="paramname"><em>vec_in</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t&#160;</td>
          <td class="paramname"><em>dim_vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">q7_t *&#160;</td>
          <td class="paramname"><em>p_out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">vec_in</td><td>pointer to input vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dim_vec</td><td>input vector dimension </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_out</td><td>pointer to output vector</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This function is an optimized version which is not bit-accurate with TensorFlow Lite's kernel </dd></dl>

<p class="reference">References <a class="el" href="arm__nnsupportfunctions_8h.html#ac9f7be20432a6926ac07c1f44b1b02fe">arm_nn_read_q7x4_ia()</a>, <a class="el" href="group__Softmax.html#ga99133c0c13daf247a40419a385d29190">LOG2Q7BITS</a>, and <a class="el" href="group__Softmax.html#ga3313178e0fcf9138c3cc3b071a043238">Q7BITS</a>.</p>

<p class="reference">Referenced by <a class="el" href="group__Softmax.html#ga894cfd80c260b946702755b5754e520f">arm_softmax_with_batch_q7()</a>, and <a class="el" href="arm__nnexamples__cifar10_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main()</a>.</p>

</div>
</div>
<a id="gad04612a258414266a706b58ca258dc1d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad04612a258414266a706b58ca258dc1d">&#9670;&nbsp;</a></span>arm_softmax_s8()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_softmax_s8 </td>
          <td>(</td>
          <td class="paramtype">const int8_t *&#160;</td>
          <td class="paramname"><em>input</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>num_rows</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>row_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>mult</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>shift</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int8_t&#160;</td>
          <td class="paramname"><em>diff_min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int8_t *&#160;</td>
          <td class="paramname"><em>output</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Pointer to the input tensor </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">num_rows</td><td>Number of rows in the input tensor </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">row_size</td><td>Number of elements in each input row </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">mult</td><td>Input quantization multiplier </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">shift</td><td>Input quantization shift within the range [0, 31] </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">diff_min</td><td>Minimum difference with max in row. Used to check if the quantized exponential operation can be performed </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Pointer to the output tensor</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Supported framework: TensorFlow Lite micro (bit-accurate) </dd></dl>

<p class="reference">References <a class="el" href="arm__softmax__s8_8c.html#a401e2dfaf6a8f0ef34f15295e026fd79">ACCUM_BITS</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#abe05f0e80d965ae31dec16ba4063f48a">CLAMP</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a7ce5ee6d8839bf541fb4bbdf4ef80eb1">DIV_POW2</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a0e4379e9eef514ce88d02b5dfbff256d">DIV_POW2_MVE</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a97055bb1e8a21ead129caecdfb24cfb1">EXP_ON_NEG</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#ad935f1ff1a50822e317bdb321ce991ad">MAX</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a518f7e0db18bea6b61a2b88f266aef20">MUL_SAT</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a6349818fec8167dff87c3fb7ca81fc1c">MUL_SAT_MVE</a>, and <a class="el" href="arm__nnsupportfunctions_8h.html#a82ac477c930f5b05e8f71f6f61e405a8">ONE_OVER1</a>.</p>

</div>
</div>
<a id="gaa1627ed96bd597a8046d00689f077dce"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa1627ed96bd597a8046d00689f077dce">&#9670;&nbsp;</a></span>arm_softmax_u8()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_softmax_u8 </td>
          <td>(</td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>input</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>num_rows</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>row_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>mult</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>shift</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int32_t&#160;</td>
          <td class="paramname"><em>diff_min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>output</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Pointer to the input tensor </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">num_rows</td><td>Number of rows in the input tensor </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">row_size</td><td>Number of elements in each input row </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">mult</td><td>Input quantization multiplier </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">shift</td><td>Input quantization shift within the range [0, 31] </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">diff_min</td><td>Minimum difference with max in row. Used to check if the quantized exponential operation can be performed </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Pointer to the output tensor</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Supported framework: TensorFlow Lite micro (bit-accurate) </dd></dl>

<p class="reference">References <a class="el" href="arm__softmax__u8_8c.html#a401e2dfaf6a8f0ef34f15295e026fd79">ACCUM_BITS</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#abe05f0e80d965ae31dec16ba4063f48a">CLAMP</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a7ce5ee6d8839bf541fb4bbdf4ef80eb1">DIV_POW2</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a97055bb1e8a21ead129caecdfb24cfb1">EXP_ON_NEG</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#ad935f1ff1a50822e317bdb321ce991ad">MAX</a>, <a class="el" href="arm__nnsupportfunctions_8h.html#a518f7e0db18bea6b61a2b88f266aef20">MUL_SAT</a>, and <a class="el" href="arm__nnsupportfunctions_8h.html#a82ac477c930f5b05e8f71f6f61e405a8">ONE_OVER1</a>.</p>

</div>
</div>
<a id="ga894cfd80c260b946702755b5754e520f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga894cfd80c260b946702755b5754e520f">&#9670;&nbsp;</a></span>arm_softmax_with_batch_q7()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_softmax_with_batch_q7 </td>
          <td>(</td>
          <td class="paramtype">const q7_t *&#160;</td>
          <td class="paramname"><em>vec_in</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t&#160;</td>
          <td class="paramname"><em>nb_batches</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t&#160;</td>
          <td class="paramname"><em>dim_vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">q7_t *&#160;</td>
          <td class="paramname"><em>p_out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">vec_in</td><td>pointer to input vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">nb_batches</td><td>number of batches </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dim_vec</td><td>input vector dimention </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_out</td><td>pointer to output vector</td></tr>
  </table>
  </dd>
</dl>
<p>Here, instead of typical natural logarithm e based softmax, we use 2-based softmax here, i.e.,:</p>
<p>y_i = 2^(x_i) / sum(2^x_j)</p>
<p>The relative output will be different here. But mathematically, the gradient will be the same with a log(2) scaling factor. </p>

<p class="reference">References <a class="el" href="group__Softmax.html#ga89aff212a97a3cf32d9d7ddf11a8f43e">arm_softmax_q7()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Mar 17 2020 15:01:26 for CMSIS-NN Version 1.2.0 by Arm Ltd. All rights reserved.
	<!--
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 
	-->
	</li>
  </ul>
</div>
</body>
</html>
